//
//  BDPostDetailModel.m
//  BadBoy
//
//  Created by wen on 2017/9/6.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDPostDetailModel.h"
#import "BDGeneralModel.h"

@implementation BDPostDetailModel

- (instancetype)initWithLayout:(BDPostLayout *)layout{
    if (self = [super init]) {
        _layout = layout;
        _shopInfo = [NSMutableArray array];
        
        if (_layout.cardHeight > 0 && [_layout.post isPurchase] == YES) {
            if ([_layout.post.shop isNotEmpty]) {
                [_shopInfo addObject:[[BDGeneralModel alloc] init].imageEqual(@"dianpu").titleEqual(_layout.post.shop)];
            }
            if ([_layout.post.address isNotEmpty]) {
                [_shopInfo addObject:[[BDGeneralModel alloc] init].imageEqual(@"dizhi").titleEqual(_layout.post.address).accessoryTypeTypeEqual(BDGeneralCellAccessoryTypeDisclosureIndicator)];
            }
            if ([_layout.post.contact isNotEmpty]) {
                [_shopInfo addObject:[[BDGeneralModel alloc] init].imageEqual(@"phone").titleEqual(_layout.post.contact).accessoryTypeTypeEqual(BDGeneralCellAccessoryTypeDisclosureIndicator)];
            }
        }
        
        if (_shopInfo.count) {
            _tableViewHeight = _layout.detailHeight + _shopInfo.count * tableViewcellHeight + tableViewSectionHeight;
        }else{
            _tableViewHeight = _layout.detailHeight;
        }
        _tableViewHeight += 20;
    }
    return self;
}

@end
